package com.lzw.breezeNovel.webApp.controller.message;

import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.webApp.service.message.MessageService;
import com.lzw.breezeNovel.webApp.vo.message.MessageVO;
import jakarta.annotation.Resource;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller.message
 * @date 2025/3/28
 * @description 控制类
 */
@RestController
@RequestMapping("/app/message")
@SuppressWarnings("all")
public class MessageController {

   /**
    * 注入service
    */
   @Resource
   private MessageService messageService;

   /**
    * 获取消息列表
    */
   @GetMapping("/list")
   @Nullable
   @Contract(pure = true)
   private Result<List<MessageVO>> getMessageList(@RequestParam Long senderId){
      List<MessageVO> messageList = messageService.getMessageList(senderId);
      return Result.ok(messageList);
   }



   /**
    * 删除消息
    */
   @GetMapping("/delete")
   private Result deleteMessage(@RequestParam Long messageId)
   {
      messageService.deleteMessage(messageId);
      return Result.ok();
   }

   /**
    * 获取用户发来的消息
    */
   @GetMapping("/get")
   private Result<List> getMessage()
   {
      List list = messageService.getMessage();
      return Result.ok(list);
   }

}
